<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="my" uri="/mytags" %>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>权限管理</title>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/asserts/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
	
		<!-- js插件 -->
		<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
		<script src="${pageContext.request.contextPath}/asserts/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
        <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/asserts/bootstrapValidate/css/bootstrapValidator.min.css"/>
 	   <script src="${pageContext.request.contextPath}/asserts/bootstrapValidate/js/bootstrapValidator.min.js"></script>
	
	</head>
	<body>
			<!-- 内容展示区 -->
			<div >
					<!-- 导航 -->
					<ol class="breadcrumb">
						<li><i class="fa fa-comment"></i> 角色权限管理</li>
					</ol>
					<div class="container-fluid">
						<!-- 	内容面板 -->
						<div class="panel panel-default">
							<!-- 控制按钮 -->
							<div class="panel-heading">
									<div class="btn-group">
										<button class="btn btn-primary" data-toggle="modal" data-target="#mymodal2" ><span class="glyphicon glyphicon-pencil"></span>添加角色权限</button>
 									</div>
							</div><!-- 控制按钮  end-->
							<div class="panel-body">
								<table class="table table-bordered table-striped table-condensed table-hover">
									<tr>
										<th width="5%"><input type="checkbox" name="" id="selectAll" /></th>
										<th width="5%">ID</th>
										<th width="20%">角色</th>
										<th width="10%">权限名</th>
										<th width="10%">资源名称</th>
										<th width="10%">访问地址</th>
										<th width="10%">操作</th>
									</tr>
									<!-- 数据绑定 -->
									<c:forEach items="${pageInfo.list}" var="au">
									<tr>
										<td><input type="checkbox" name="" class="eid" id="" /></td>
										<td>${au.id }</td>
										<td>${au.rolename }</td>
										<td>${au.authorityName }</td>
									    <td>${au.resourceName}</td>
									    <td>${au.url}</td>
										<td>
											 <button type="button" class="btn btn-danger" onclick="del(${au.id},${au.roleid})"> 
											 	<span class="glyphicon glyphicon-remove"></span> 删除</button>
											 
										</td>
									</tr>
									</c:forEach>	
								  
									<!-- 	数据绑定 end -->
								</table>
								<!-- 	分页 -->
										<!-- 	分页 -->
								 <my:page prePage="${pageInfo.prePage}" nextPage="${pageInfo.nextPage}"   url="${pageContext.request.contextPath}/authority/list?n=1" totalPage="${pageInfo.pages}"
								  currentPage="${pageInfo.pageNum}"/>
							</div>
						</div><!-- 内容面板 end -->
					</div>
			</div><!-- 	内容展示区 end-->
	 
 
		
			<!-- 弹层组件 添加标签 -->
		<div class="modal fade" id="mymodal2">
			<div class="modal-dialog">
				<div class="modal-content">
					<form action="${pageContext.request.contextPath}/authority/add"  class="form-horizontal">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
							<h4 class="modal-title" id="mylabel">设置用户角色的访问菜单权限</h4>
						</div>
						<div class="modal-body">
							  <div class="form-group">
									<label class="control-label col-md-3">用户角色：</label>
									<div class="col-md-8" >
									  <div  class="checkbox">
									   <input type="checkbox" name="roleids" value="1" />校级别账户
									    </div>
									    <div  class="checkbox">
									    <input type="checkbox" name="roleids" value="2" />镇级别账户
									    </div>
									    <div  class="checkbox">
									    <input type="checkbox" name="roleids"  value="3" />县级别账户
									    </div>
									    <div  class="checkbox">
									   	<input type="checkbox" name="roleids"  value="4" />后台管理员账户
										</div> 
									</div>
								</div>
							  
								<div class="form-group">
									<label class="control-label col-md-3">权限名称：</label>
									<div class="col-md-8">
										<input type="text" name="authorityName" placeholder="请输入权限名称（如查询在校学生）" class="form-control"  />
									</div>
								</div>
								  <div class="form-group">
									<label class="control-label col-md-3">资源名称：</label>
									<div class="col-md-8">
										<input type="text" name="resourceName" placeholder="请输入资源名称（如在校学生查询）" class="form-control"  />
									</div>
								</div>
								  <div class="form-group">
									<label class="control-label col-md-3">资源访问地址：</label>
									<div class="col-md-8">
										<input type="text" name="url" placeholder="请输入请求的url地址 （如'/sams/student/list'）" class="form-control"  />
									</div>
								</div>
								
								
								 
						</div>
						<div class="modal-footer">
							<button class="btn btn-danger" type="button">关闭</button>
							<button class="btn btn-primary" type="submit">录入</button>
						</div>
					</form>
				</div>
			</div>
		</div><!-- 弹层组件 添加标签 end -->
	 
	</body>
</html>
<script>
	 $(function () {
	  
        $('form').bootstrapValidator({
　　　　　　　　message: 'This value is not valid',
            　feedbackIcons: {
                　　　　　　　　valid: 'glyphicon glyphicon-ok',
                　　　　　　　　invalid: 'glyphicon glyphicon-remove',
                　　　　　　　　validating: 'glyphicon glyphicon-refresh'
            　　　　　　　　   },
            fields: {
            	resourceName: {
                    message: '用户名验证失败',
                    validators: {
                        notEmpty: {
                            message: '资源 名称不能为空'
                        }
                    }
                },url: {
                    message: '用户名验证失败',
                    validators: {
                        notEmpty: {
                            message: '资源url不能为空'
                        }
                    }
                },
                authorityName: {
                    validators: {
                        notEmpty: {
                            message: '权限名称不能为空'
                        }
                    }
                } ,
                roleids: {
                    validators: {
                        notEmpty: {
                            message: '用户角色不能为空'
                        }
                    }
                } 
            } ,
            submitHandler: function (validator, form, submitButton) {
              // alert("submit");
            }
        });
    });
	 
	 function del(id,roleid){
		var flag =  confirm("确认是否要删除吗？");
		var path =''
		
		if(flag){
			location.href="delete?auid="+id+"&roleid="+roleid;
		}
	 }
	 document.documentElement.style.overflowY = 'hidden';
</script>